<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组件的嵌套</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
    <div id="root">
        <!-- <school></school>
        <hello></hello> -->
        <app></app>
    </div>
</body>

<script type="text/javascript">

    Vue.config.productionTip = false;

    // 定义组件
    const student = Vue.extend({
        name: 'student',
        template: `
            <div>
                <h2>{{name}}</h2>    
                <h2>{{age}}</h2>    
            </div>
        `,
        data(){
            return {
                name: 'chenjt同学',
                age: '18'
            }
        }
    })

    // 定义组件
    const school = Vue.extend({
        name: 'school',
        template: `
            <div>
                <h2>{{name}}</h2>    
                <h2>{{address}}</h2>  
                <student></student>  
            </div>
        `,
        data(){
            return {
                name: 'chenjt',
                address: 'address'
            }
        },
        components: {
            student
        }
    })


    // 定义组件
    const hello = Vue.extend({
        name: 'hello',
        template: `
            <div>
                <h1>{{name}}</h1>    
            </div>
        `,
        data(){
            return {
                name: 'hello comonent'
            }
        }
    })
    

    // 定义组件
    const app = Vue.extend({
        template: `
            <div>
                <hello></hello>
                <school></school>  
            </div>
        `,
        components: {
            school,
            hello
        }
    })
    

    new Vue({
        // template: `<app></app>`,
        el: '#root',
        // 注册组件（局部）
        components: {
            // school,
            // hello
            app
        }
    })


</script>

</html>